home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT36.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.0 KB  |  83 lines

  1. /*
  2. ==============================================================================
  3.                       WordUp Graphics Toolkit Version 5.0                     
  4.                              Demonstration Program 36                         
  5.                                                                               
  6.  This program shows how the wxorbox routine works.                           
  7.                                                                               
  8.  *** PROJECT ***                                                             
  9.  This program requires the file WGT5_WC.LIB to be linked.                    
  10.                                                                               
  11.  *** DATA FILES ***                                                          
  12.  None                                                                        
  13.                                                            WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <wgt5.h>
  18.  
  19. short oldmode;
  20. short ox, oy;  /* old mouse coordinates */
  21. short i;
  22.  
  23.  
  24. void main(void)
  25. {
  26.  
  27.   if ( !vgadetected () )
  28.   {
  29.     printf("Error - VGA card required for any WGT program.\n");
  30.     exit (0);
  31.   }
  32.  
  33.   printf ("WGT Example #36\n\n");
  34.   printf ("Draws a bar using WXORBOX to highlight regions. Click the mouse button\n");
  35.   printf ("to advance to the next box type. The second demo uses four commands to simulate\n");
  36.   printf ("a rectangle. Another mouse click ends the program.\n");
  37.   printf ("\n\nPress any key to continue.\n");
  38.   getch ();
  39.  
  40.   oldmode = wgetmode ();         /* Gets the current mode */
  41.   vga256 ();                     /* Initialize graphics mode */
  42.  
  43.   minit ();
  44.   
  45.   for (i = 0; i < 200; i++) /* Draw a background */
  46.    {
  47.     wsetcolor (i);
  48.     wline (0, i, 319, i);
  49.    }
  50.  
  51.   do {  /* Draws a filled xorbox using mouse coordinates as one corner. */
  52.    ox = mouse.mx;
  53.    oy = mouse.my;
  54.    wxorbox (50, 50, ox, oy, 128);    /* Draw the box */
  55.    while ((mouse.mx == ox) && (mouse.my == oy) && (!mouse.but))
  56.       wretrace ();
  57.    /* Do nothing while mouse is stationary. */
  58.    wxorbox (50, 50, ox, oy, 128);             
  59.     /* Erase the box by drawing the same thing */
  60.   } while (mouse.but == 0);
  61.  
  62.   noclick ();
  63.  
  64.   do {  /* Draws a hollow rubber box using mouse coordinates as one corner. */
  65.    ox = mouse.mx;
  66.    oy = mouse.my;
  67.    wxorbox (50, 50, ox, 50, 128);
  68.    wxorbox (ox, 50, ox, oy, 128);    /* Draw the box */
  69.    wxorbox (50, oy, ox, oy, 128);
  70.    wxorbox (50, 50, 50, oy, 128);
  71.    while ((mouse.mx == ox) && (mouse.my == oy) && (!mouse.but))
  72.       wretrace ();
  73.    /* Do nothing while mouse is stationary. */
  74.    wxorbox (50, 50, ox, 50, 128);
  75.    wxorbox (ox, 50, ox, oy, 128);    /* Erase the box */
  76.    wxorbox (50, oy, ox, oy, 128);
  77.    wxorbox (50, 50, 50, oy, 128);
  78.   } while (mouse.but == 0);
  79.   mdeinit ();                   /* Deinitialize the mouse handler */
  80.  
  81.  wsetmode (oldmode);
  82. }
  83.